@extends('backend.layouts.master')

@section('title', '编辑商品')

@section('content')
  <div class="admin-content">
    <div class="am-cf am-padding">
      <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">编辑商品</strong> / <small> </small></div>
    </div>

    <hr/>

    <div  @if  (!Session::get('message')) style="display:none;" @endif  class="am-alert  @if  (Session::get('message.type')=='s')am-alert-success @endif @if (Session::get('message.type')=='w')am-alert-warning @endif @if (Session::get('message.type')=='d')am-alert-danger @endif" data-am-alert>
      <button type="button" class="am-close">&times;</button>
      <p>{{ Session::get('message.message') }}</p>
    </div>

    <div class="am-g" style="min-height: 600px">


      <div class="am-u-sm-12 am-u-md-8 am-u-md-pull-12">
        <form class="am-form am-form-horizontal" enctype="multipart/form-data" action="{{url('backend/update')}}" method="post">
          <input type="hidden" name="id" value="{{$shop->id}}">
          <div class="am-form-group">
             <label for="user-name" class="am-u-sm-3 am-form-label">标题</label>
            <div class="am-u-sm-9">
              <input type="text" name="title" value="{{$shop->title}}"  >
            </div>
          </div>

          <div class="am-form-group">
            <label for="user-email" class="am-u-sm-3 am-form-label">内容</label>
            <div class="am-u-sm-9">
              {{--<input type="text" name="content" value="{{$shop->content}}" >--}}
              <textarea rows="10"  name="content" placeholder="">{{$shop->content}}</textarea>
            </div>
          </div>

          <div class="am-form-group">
            <label for="user-email" class="am-u-sm-3 am-form-label">积分</label>
            <div class="am-u-sm-9">
              <input type="number" name="score"  value="{{$shop->score}}">
            </div>
          </div>


          <div class="am-form-group">
            <label for="user-email" class="am-u-sm-3 am-form-label">数量</label>
            <div class="am-u-sm-9">
              <input type="number" name="num" value="{{$shop->num}}">
            </div>
          </div>



          <div class="am-form-group">
            <label for="user-email" class="am-u-sm-3 am-form-label">图片</label>
            <div class="am-u-sm-9">
              <input type="file" name="pic" id="user-pic">
              <p class="am-form-help">请选择要上传的文件...</p>
              @if ($shop->pic)
                <p>
                  <img src="/uploads/{{$shop->pic}}" style="width: 200px" />
                </p>
              @endif
            </div>
          </div>



          <div class="am-alert am-alert-danger" id="my-alert" style="display: none">
            <p>开始日期应小于结束日期！</p>
          </div>

          <div class="am-form-group">
            <label for="user-email" class="am-u-sm-3 am-form-label">开始时间</label>
            <div class="am-u-sm-9">
              <p><input type="text" name="start_at" value="{{date('Y-m-d',$shop->start_at)}}" class="am-form-field" placeholder="日历组件" data-am-datepicker="{theme: 'success'}" id="my-start" readonly/></p>
            </div>
          </div>


          <div class="am-form-group">
            <label for="user-email" class="am-u-sm-3 am-form-label">开始时间</label>
            <div class="am-u-sm-9">
              <p><input type="text" name="end_at" value="{{date('Y-m-d',$shop->end_at)}}" class="am-form-field" placeholder="日历组件" data-am-datepicker="{theme: 'success'}" id="my-end" readonly/></p>
            </div>
          </div>

          <div class="am-form-group">

            <label for="user-email" class="am-u-sm-3 am-form-label">状态</label>

            <div class="am-u-sm-9">
              <div class="am-btn-group" data-am-button>
                <label class="am-btn am-btn-default am-btn-xs @if ($shop->status==0) am-active @endif">
                  <input type="radio" name="status" value="0" @if ($shop->status==0) checked @endif> 不上架
                </label>
                <label class="am-btn am-btn-default am-btn-xs  @if ($shop->status==1) am-active @endif">
                  <input type="radio" name="status" value="1" @if ($shop->status==1) checked @endif> 上架
                </label>
              </div>
            </div>
          </div>



          <div class="am-form-group">
            <div class="am-u-sm-9 am-u-sm-push-3">
              <button type="submit" class="am-btn am-btn-primary">保存修改</button>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
  <!-- content end -->
@stop
@section('js')
  <script>
    $(function() {
      var startDate = new Date(2014, 11, 20);
      var endDate = new Date(2014, 11, 25);
      var $alert = $('#my-alert');
      $('#my-start').datepicker().
              on('changeDate.datepicker.amui', function(event) {
                if (event.date.valueOf() > endDate.valueOf()) {
                  $alert.find('p').text('开始日期应小于结束日期！').end().show();
                } else {
                  $alert.hide();
                  startDate = new Date(event.date);
                  $('#my-startDate').text($('#my-start').data('date'));
                }
                $(this).datepicker('close');
              });

      $('#my-end').datepicker().
              on('changeDate.datepicker.amui', function(event) {
                if (event.date.valueOf() < startDate.valueOf()) {
                  $alert.find('p').text('结束日期应大于开始日期！').end().show();
                } else {
                  $alert.hide();
                  endDate = new Date(event.date);
                  $('#my-endDate').text($('#my-end').data('date'));
                }
                $(this).datepicker('close');
              });
    });
  </script>
  @stop